<?php
////////////////////////////////////////////////////////////////////////////////
//   Copyright (C) ReloadCMS Development Team                                 //
//   http://reloadcms.sf.net                                                  //
//                                                                            //
//   This program is distributed in the hope that it will be useful,          //
//   but WITHOUT ANY WARRANTY, without even the implied warranty of           //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
//                                                                            //
//   This product released under GNU General Public License v2                //
////////////////////////////////////////////////////////////////////////////////
header("Content-type: image/png");
class counter {
//method which draws counter image
function draw($showtext){
$image = imagecreatefrompng("content/gstats/icon.png");
$colorBackgr = imageColorAllocate($image, 0, 0, 0);
$textlenght=sizeof($showtext);
for ($i=0;$i<$textlenght;$i++) {
$colorText = imageColorAllocate($image, 0, 40, 255);
}
imageString($image, 6, 60, 8,  $showtext ,$colorText);
imagePNG($image);
}
// method which returns hits count
function get_stats() {
         $stats=file_get_contents("content/gstats/gstats.dat");
         return($stats);
         }
// method which adds +1 to counter stats
function add_stats() {
         $stats=file_get_contents("content/gstats/gstats.dat");
         $stats++;
         file_put_contents("content/gstats/gstats.dat",$stats);
         }

}
// main code part
$counter= new counter();
$counter->add_stats();
$counter->draw($counter->get_stats());
?>
